﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChartSharp
{
    public enum BarsDirection
    {
        Horizontal = 'h',
        Vertical = 'v',
    }

    public enum BarsType
    {
        Stacked = 's',
        Grouped = 'g',
    }

    public class BarChart : Chart
    {
        protected BarSize _barChartSize;
        protected BarZeroLine _barZeroLine;
        protected AxisType _types;
        protected AxisRange _ranges;
        protected AxisLabels _labels;
        protected DataScale _dataScales;

        public BarChart(BarsType type, BarsDirection direction)
            : base(GetBarChartType(type, direction))
        {
        }

        public BarChart(BarsType type, BarsDirection direction, int width, int height)
            : base(GetBarChartType(type, direction), new Size(width, height))
        {
        }

        public BarChart(BarsType type, BarsDirection direction, Size size)
            : base(GetBarChartType(type, direction), size)
        {
        }

        public BarChart(BarsType type, BarsDirection direction, Size size, DataSets data)
            : base(GetBarChartType(type, direction), size, data)
        {
        }

        public BarChart ZeroLine(float zeroLine)
        {
            _barZeroLine = new BarZeroLine(zeroLine);
            return this;
        }

        public BarChart ZeroLine(BarZeroLine zeroLine)
        {
            _barZeroLine = zeroLine;
            return this;
        }

        public BarChart BarSize(int width)
        {
            _barChartSize = new BarSize(width);
            return this;
        }

        public BarChart BarSize(int width, int space)
        {
            _barChartSize = new BarSize(width, space);
            return this;
        }

        public BarChart BarSize(BarSize size)
        {
            _barChartSize = size;
            return this;
        }

        public BarChart AxisType(AxisType types)
        {
            _types = types;
            return this;
        }

        public BarChart AxisRange(AxisRange ranges)
        {
            _ranges = ranges;
            return this;
        }

        public BarChart AxisLabel(AxisLabels labels)
        {
            _labels = labels;
            return this;
        }

        public BarChart DataScale(DataScale dataScales)
        {
            _dataScales = dataScales;
            return this;
        }

        private static Type GetBarChartType(BarsType type, BarsDirection direction)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("b");
            builder.Append((char)direction);
            builder.Append((char)type);
            return new Type(builder.ToString());
        }
    }
}
